//
//  CellOfcollection1.m
//  HYHOME
//
//  Created by Mac on 16/1/26.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "CellOfcollection1.h"
#import "ModelImage.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"
@implementation CellOfcollection1


- (void)dealloc{

    [_picUrl release];
    [_catname release];
    [super dealloc];


}
-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.dk_backgroundColorPicker = DKColorWithRGB(0xF5F5FF, 0x343434);
        // 创建子控件
        self.picUrl = [[UIImageView alloc]init];
        [self.contentView addSubview:self.picUrl];

        self.catname = [[UILabel alloc]init];
        [self.contentView addSubview:self.catname];
        self.catname.textAlignment = NSTextAlignmentCenter;
        
        
        
        [self.picUrl release];
        [self.catname release];
        
        
    }
    
    return self;
    
}



- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    self.picUrl.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.frame.size.height-100);
    self.catname.frame = CGRectMake(0,self.frame.size.height-100, self.contentView.frame.size.width,50);
    self.catname.textAlignment = NSTextAlignmentCenter;
    self.catname.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor lightGrayColor]);

    
}


-(UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
      
    return layoutAttributes;
}



- (void)layoutSubviews{
    
    
    [super layoutSubviews];
    
}

-(void)passModel:(ModelImage *)model{
    
    [self.picUrl sd_setImageWithURL:[NSURL URLWithString:model.picUrl]  placeholderImage:[UIImage imageNamed:@"jz"]];
    self.catname.text = model.catname;
    
}

@end
